#include<bits/stdc++.h>
#define ls tr[p].ch[0]
#define rs tr[p].ch[1]
using namespace std;
struct f{int l,r;}a[500005],b[500005];
vector<int>s[1000005],v[1000005];
int main(){
    freopen("stone.in","r",stdin);
    freopen("stone.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int q;cin>>q;
        int cnt=0;
        while(q--){
            char op;int l,r;
            cin>>op>>l>>r;r--;
            if(op=='A'){
                int pd=0,pdd=0;
                for(int i=cnt;i>=1;i--){
                    if(a[i].l<=l&&pd==0){a[i+1].l=l,a[i+1].r=r;pd=1;}
                    if(b[i].r<=r&&pdd==0){b[i+1].l=l,b[i+1].r=r,pdd=1;}
                    if(pd==0) swap(a[i],a[i+1]);
                    if(pdd==0) swap(b[i],b[i+1]);
                    if(pd&&pdd) break;
                }
                if(pd==0) a[1].l=l,a[1].r=r;
                if(pdd==0) b[1].l=l,b[1].r=r;
                cnt++;
            }
            else{int pd=0,pdd=0;
                for(int i=1;i<=cnt;i++){
                    if(pd||(a[i].l==l&&a[i].r==r)){swap(a[i],a[i+1]);pd=1;}
                    if(pdd||(b[i].l==l&&b[i].r==r)){pdd=1,swap(b[i],b[i+1]);}
                }cnt--;
            }
            // for(int i=1;i<=cnt;i++) cout<<b[i].l<<" "<<b[i].r<<'\n';cout<<"whxx"<<'\n';
            // cout<<cnt<<"whxx"<<'\n';
            // for(int i=1;i<cnt;i++) if(b[i+1].r<b[i].r) return cout<<"whxx",0;
            int num=0,mi=INT_MAX,ans=INT_MAX,sum=INT_MAX;l=1;
            for(int i=1;i<=cnt;i++){
                if(ans>b[i].r-b[i].l+1) ans=sum=b[i].r-b[i].l+1;
                if(ans==b[i].r-b[i].l+1&&sum>b[i].r-b[i].l+1) sum=b[i].r-b[i].l+1;
                while(l<=cnt&&a[l].l<=b[i].r){
                    if(num<a[l].l) num=a[l].l,mi=a[l].r;
                    if(num==a[l].l) mi=min(mi,a[l].r);
                    l++;
                }
                if(mi>b[i].r&&num>b[i].l){
                    if(ans>b[i].r-num+1) ans=b[i].r-num+1,sum=mi-b[i].l+1;
                    if(ans==b[i].r-num+1) sum=min(sum,mi-b[i].l+1);
                }
            }l=1;mi=0;
            for(int i=1;i<=cnt;i++){
                while(l<=cnt&&b[l].r<a[i].l){mi=max(mi,b[l].l);l++;}
                // cout<<a[i].r<<" "<<mi<<'\n';
                if(mi!=0){//cout<<"whxx"<<'\n';
                    // cout<<a[i].r<<" "<<mi<<'\n';
                    if(ans!=0) ans=0,sum=a[i].r-mi+1;
                else sum=min(sum,a[i].r-mi+1);
               }
           }
        cout<<sum<<'\n';
    }
    return 0;
}